<template>
    <div class="mod-config">
        <basic-container>
            <div class="boxsty zhiBiao">
                <el-row :gutter="20">
                  <el-col :span='24' style="overflow:hidden;border-bottom:1px solid #0e258c;margin-bottom:20px;">
                      <span style="float:left;font-size:24px;margin-bottom:10px;">专项工作</span>
                      <div style="text-align:right;float:right">
<!--                          <el-button type="primary">导出</el-button>-->
<!--                          <el-button type="primary">导入</el-button>-->
                          <el-button type="primary" @click="fanH">返回</el-button>
                      </div>
                  </el-col>
                  <el-col :xs="24" :sm="24" :md="12" style="text-align:center;">
                      <h3>评价人</h3>
                      <el-table
                        style="width: 100%;margin-top:20px"
                        :data="dataList"
                        border
                        highlight-current-row
                        @row-click='rowClick'
                        v-loading="dataListLoading">
                        <!-- <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column> -->
                        <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
                        <el-table-column
                            prop="pfryname"
                            header-align="center"
                            align="center"
                            label="姓名">
                        </el-table-column>
                        <el-table-column
                            prop="pfrydepartname"
                            header-align="center"
                            align="center"
                            label="所在机构">
                        </el-table-column>
                      </el-table>
                  </el-col>
                  <el-col :xs="24" :sm="24" :md="12" style="text-align:center;">
                      <h3>参与人</h3>
                      <el-table
                        style="width: 100%;margin-top:20px"
                        :data="dataList1"
                        border
                        v-loading="dataListLoading">
                        <!-- <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column> -->
                        <el-table-column type="index" width="80" header-align="center" align="center" label="序号"></el-table-column>
                        <el-table-column
                            prop="cyryname"
                            header-align="center"
                            align="center"
                            label="姓名">
                        </el-table-column>
                        <el-table-column
                            prop="cyrydepartname"
                            header-align="center"
                            align="center"
                            label="所在机构">
                        </el-table-column>
                        <el-table-column
                          prop="yifenqz"
                          header-align="center"
                          align="center"
                          label="已分权重 %">
                          <template slot-scope="scope">
                            <el-popover
                              placement="left"
                              width="300"
                              trigger="hover">
                              <el-table :data="scope.row.gridData">
                                <el-table-column min-width="90" property="pfry" label="打分人"></el-table-column>
                                <el-table-column min-width="90" property="quanz" label="权重 %"></el-table-column>
                              </el-table>
                              <div slot="reference" class="name-wrapper">
                                <span  style="cursor: pointer;">{{scope.row.yifenqz}}</span>
                              </div>
                            </el-popover>
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="shstate"
                          header-align="center"
                          align="center"
                          label="审核状态">
                          <template slot-scope="scope">
                            <div slot="reference" class="name-wrapper">
                              <span v-if="scope.row.shstate == 0">未审批</span>
                              <span v-if="scope.row.shstate == 1">审批通过</span>
                              <span v-if="scope.row.shstate == -1">审批驳回</span>
                            </div>
                          </template>
                        </el-table-column>
                        <el-table-column
                            prop="quanzhong"
                            header-align="center"
                            align="center"
                            label="权重 %">
                          <template slot-scope="scope">
                            <el-input type="number" :disabled="scope.row.shstate==1" v-model="scope.row.quanzhong" @change="yanZheng(scope.row)"></el-input>
                          </template>
                        </el-table-column>
                      </el-table>
                  </el-col>

                </el-row>
            </div>
        </basic-container>
    </div>
</template>

<script>
import {zxpjList,zxcyList,getCyrById,saveRow} from "@/api/hetongrenwu/zhuanxianggongzuo/zxgzchuangjian";

export default {
  props:{
    zxid:Number
  },
    name:'zxpj-form',
    data(){
        return{
            dataList:[],
            dataList1:[],
            dataListLoading:false,
            zxId:0,
            pfryId:0,
            gridData:[]
        }
    },
    created() {
      this.getDataList()
    },
    methods:{
      yanZheng(row){
          saveRow( Object.assign(row,{pfryId:this.pfryId})).then(response => {
              zxcyList(Object.assign({
                zxId:this.zxid,
                pfryId:this.pfryId,
                type:this.radio,
                current: this.pageIndex,
                size: this.pageSize
              })).then(response => {
                this.dataList1 = response.data.data.records
                this.totalPage = response.data.data.total
              })
          }) ;
      },
        // 获取数据列表
        getDataList() {
          this.dataListLoading = true
          zxpjList(Object.assign({
            zxId:this.zxid,
            type:this.radio,
            current: this.pageIndex,
            size: this.pageSize
          })).then(response => {
            this.dataList = response.data.data.records
            this.pfryId=this.dataList[0].pfryid
            this.totalPage = response.data.data.total
            zxcyList(Object.assign({
              pfryId:this.pfryId,
              zxId:this.zxid,
              type:this.radio,
              current: this.pageIndex,
              size: this.pageSize
            })).then(response => {
              this.dataList1 = response.data.data.records
              this.totalPage = response.data.data.total
            })
          })

          this.dataListLoading = false

        },
        //点击某行
        rowClick(row){
          this.pfryId = row.pfryid;
          this.pfryId= row.pfryid;
          getCyrById(Object.assign({
              zxId:this.zxid,
              pfryId:row.pfryid,
              type:this.radio,
              current: this.pageIndex,
              size: this.pageSize
            })).then(response => {
              this.dataList1 = response.data.data.records
              this.totalPage = response.data.data.total
            })
        },
        fanH(){
            this.$emit('zxpjC','返回')
        },
    }
}
</script>

<style>

</style>
